
#ifndef __I2C_H__
#define __I2C_H__
#include "gd32f4xx.h"
#include "systick.h"

// i2c 执行情况
#define I2C_RESULT_OK            0
#define I2C_ERR_DEVICE_ADDR      1
#define I2C_ERR_REGISTER_ADDR    2
#define I2C_ERR_WRITE            3
#define I2C_ERR_READ             4

#define I2C_SCL_PORT   GPIOB
#define I2C_SCL_PIN    GPIO_PIN_6
#define I2C_SCL_RCU    RCU_GPIOB

#define I2C_SDA_PORT   GPIOB
#define I2C_SDA_PIN    GPIO_PIN_7
#define I2C_SDA_RCU    RCU_GPIOB

#define I2C_SCL_AF    GPIO_AF_4
#define I2C_SDA_AF    GPIO_AF_4
#define I2C_X         I2C0
#define I2C_RCU       RCU_I2C0
#define I2C_SPEED     100000


void i2c_hard_init();
uint8_t i2c_hard_read(uint8_t addr, uint8_t reg, uint8_t* data, uint32_t len);
uint8_t i2c_hard_write(uint8_t addr, uint8_t reg, uint8_t* data, uint32_t len);
#endif